package com.lczyfz.campusinfo.modules.campusinfoeducation.web;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.lczyfz.campusinfo.common.utils.ApiResultUtils;
import com.lczyfz.campusinfo.common.web.BaseController;
import com.lczyfz.campusinfo.modules.campusinfoeducation.entity.CampusinfoCollege;
import com.lczyfz.campusinfo.modules.campusinfoeducation.entity.CampusinfoMajor;
import com.lczyfz.campusinfo.modules.campusinfoeducation.service.CampusinfoMajorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping(value = "api/campusinfoeducation/campusinfoMajor")
public class CampusinfoApiMajor extends BaseController {

    @Autowired
    private CampusinfoMajorService campusinfoMajorService;
    @RequestMapping(value = "majorList")
    @ResponseBody
    public List<Map<String, Object>> allType(String schoolid ,String collegeid,HttpServletRequest request, HttpServletResponse response) {

        List<Map<String, Object>> mapList = Lists.newArrayList();
        CampusinfoMajor campusinfoMajor = new CampusinfoMajor();
        campusinfoMajor.setSchoolid(schoolid);
        campusinfoMajor.setCollegeid(collegeid);
        List<CampusinfoMajor> campusinfoMajorList = campusinfoMajorService.findList(campusinfoMajor);
        for (int i = 0; i <  campusinfoMajorList.size(); i++) {
            Map<String, Object> map = ApiResultUtils.getBaseMapSuccess();
            CampusinfoMajor e =  campusinfoMajorList.get(i);
            map.put("id", e.getId());
            map.put("name", e.getMajorname());
            map.put("payment", e.getPayment());
            map.put("unlinepayment",e.getMajorcontent());
            mapList.add(map);
        }
        return mapList;
    }
}
